﻿@inherits BaseDialogPage<MenuTree>

<EditDialog Model="Model" OnSaveAsync="SaveAsync">
    <BodyTemplate>
        <div class="row">
            <div class="form-group col-12">
                <BootstrapInput @bind-Value="@Model.ParentMenuName" IsDisabled="true" />
            </div>
            <div class="form-group col-12">
                <BootstrapInput @bind-Value="@Model.Name" />
            </div>
            <div class="form-group col-12">
                <BootstrapInput @bind-Value="@Model.Code" />
            </div>
            <div class="form-group col-12">
                <BootstrapInput @bind-Value="@Model.Rotue" />
            </div>
            <div class="form-group col-12">
                <BootstrapInput @bind-Value="@Model.Icon" />
            </div>
            <div class="form-group col-12">
                <Checkbox @bind-Value="@Model.IsEnabled" />
            </div>
            <div class="form-group col-12">
                <Checkbox @bind-Value="@Model.IsDefaultParmisson" />
            </div>

        </div>
    </BodyTemplate>

</EditDialog>


@code {


    private async Task SaveAsync(EditContext context)
    {
        var operateResult = await AccountClientFactory.Menu.CreateMenu(Model);
        if (operateResult.IsSuccess == true)
        {
            await this.Alert("保存成功!");
            await this.ParentPage.Refresh(null);

        }
        else
        {
            await this.Alert("保存失败!" + operateResult.Message);
        }
    }

    private async Task OnInvalidSubmit(EditContext context)
    {

        await Task.CompletedTask;
    }

}
